//
//  BaseHander.h
//  GeneralProject
//
//  Created by zhangkai on 15/10/19.
//  Copyright © 2015年 AC. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "BaseRequestModel.h"
#import "RequestResultModel.h"
#import "CacheDataLayer.h"

@interface HttpHander : NSObject

@property(nonatomic, strong) NSMutableDictionary *memoryCache;/**< 内存缓存 */

+ (instancetype)shared;

//- (void)clearMemoryCache;

//如果不需要在hander中做特殊数据处理，均可用通用hander：HttpHander调用下面的方法

//requestName从requestDefine中取
//delegete为调用回调方法method的类，通常为调用该请求的vc
//回调方法的名称在调用的地方定义，回调方法的参数统一为RequestResultModel类

//post异步请求
-(void)postAsyncRequestWithRequestName:(NSString *)requestName requestModel:(BaseRequestModel *)requestModel delegate:(id)delegate method:(SEL)sel;


//get异步请求
-(void)getAsyncRequestWithRequestName:(NSString *)requestName requestModel:(BaseRequestModel *)requestModel delegate:(id)delegate method:(SEL)sel;


//带缓存的请求方法
-(void)sendAsyncRequestWithRequestModel:(BaseRequestModel *)requestModel;

//带缓存的回调方法
-(void)requestCacheCallBack:(NSDictionary *)retDic;

//根据请求url获取缓存片缓存文件名
-(NSString *)getCacheNameWithUrl:(NSString *)url;


//根据name保存内存缓存
-(void)saveData:(NSDictionary *)data ToMemoryName:(NSString *)name;

//根据name取内存缓存
-(NSDictionary *)getDataWithMemoryName:(NSString *)name;

@end
